package yunwo.cn.yzstation.adapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import java.util.HashMap;
import java.util.Map;

import yunwo.cn.yzstation.R;
import yunwo.cn.yzstation.base.BasicAdapter;
import yunwo.cn.yzstation.bean.CarBean;

/**
 * Created by lao on 2017/10/11.
 */

public class CarAdapter extends BasicAdapter<CarBean.DataBean> {
    HashMap<String, String> map;
    public CarAdapter(Context mctx, HashMap<String,String> map ) {
        super(mctx);
        this.map = map;
    }

    @Override
    protected int setItemLayout() {
        return R.layout.car_item;
    }

    @Override
    protected void bindData(View convertView, CarBean.DataBean data, int position) {
        TextView platNumber = get(convertView, R.id.platNumber);
        TextView vehicleType = get(convertView, R.id.vehicleType);
        platNumber.setText(data.getPlatNumber());
        vehicleType.setText(data.getVehicleTypeName());

    }
    public static String getKey(HashMap<String,String> map, String value){
        String key = null;
        //Map,HashMap并没有实现Iteratable接口.不能用于增强for循环.
        for(String getKey: map.keySet()){
            if(map.get(getKey).equals(value)){
                key = getKey;
            }
        }
        return key;
        //这个key肯定是最后一个满足该条件的key.
    }
}
